package org.luxor.commons.zookeeper.watcher;

import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent;
import org.apache.curator.framework.recipes.cache.PathChildrenCacheListener;
import org.luxor.commons.zookeeper.annotation.ZookeeperWatcher;
import org.luxor.commons.zookeeper.constant.Watcher;
import org.springframework.stereotype.Component;

@Component
@ZookeeperWatcher(value = ChildrenWatcher.PATH, watcher = Watcher.PathChildrenCache)
public class ChildrenWatcher implements PathChildrenCacheListener {
    public static final String PATH = "/watcher";

    @Override
    public void childEvent(CuratorFramework client, PathChildrenCacheEvent event) throws Exception {
        System.out.println("==========ChildrenWatcher start==============");
        System.out.println("ChildrenWatcher event: " + event);
        System.out.println("==========ChildrenWatcher end==============");
    }
}
